<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>menu</title>
    <link rel="stylesheet" href="../layui/css/layui.css" media="all">
<!--    <link rel="stylesheet" href="../css/public.css" media="all">-->
<!--    <style>-->
<!--        .layui-btn:not(.layui-btn-lg ):not(.layui-btn-sm):not(.layui-btn-xs) {-->
<!--            height: 34px;-->
<!--            line-height: 34px;-->
<!--            padding: 0 8px;-->
<!--        }-->
<!--    </style>-->
</head>
<body>
<div class="layuiMini-container">
    <div class="layuiMini-main">
        <div>
            <div class="layui-btn-group">
                <button class="layui-btn" id="btn-expand">全部展开</button>
                <button class="layui-btn" id="btn-fold">全部折叠</button>
            </div>
            <table id="munu-table" class="layui-table" lay-filter="munu-table"></table>
        </div>
    </div>
</div>
<!-- 操作列 -->
<script type="text/html" id="auth-state">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>

<script src="../layui/layui.js" charset="utf-8"></script>
<script src="../js/lay-config.js" charset="utf-8"></script>
<style>
    .layui-table-cell {
        overflow: initial;
    }
</style>
<style>
    .layui-table-cell {
        overflow: initial;
    }

    td .layui-form-selected dl{
        top:30px !important;
    }
    td .layui-select,.layui-select-title .layui-input{
        height:28px !important;
        padding-left: 10px;
    }
    td .layui-form-select dl dd, .layui-form-select dl dt{
        line-height:26px;
    }

</style>
<script>
    layui.use(['table', 'treeTable'], function () {
        var $ = layui.jquery;
        var table = layui.table;
        var treeTable = layui.treeTable;

        // 渲染表格
        layer.load(2);
        treeTable.render({
            treeColIndex: 1,
            treeSpid: -1,
            treeIdName: 'authorityId',
            treePidName: 'parentId',
            elem: '#munu-table',
            url: '/PAGE-INFO/api/menus.json',
            page: false,
            cols: [[
                {type: 'numbers'},
                {field: 'authorityName', minWidth: 200, title: '权限名称'},
                {
                    field: 'authority',templet:function(d){
                        if(d.parentId==7){
                            return "-->"+d.authority;
                        }else if(d.parentId==2){
                            let str = '';
                            str+='';
                            // str+='<div class="layui-input-inline">';
                            str+='<select name="quiz1">';
                            str+='<option value="">请选择省</option><option value="浙江" selected="">浙江省</option><option value="你的工号">江西省</option><option value="你最喜欢的老师">福建省</option>';
                            str+='</select>';
                            // str+='</div>';
                            return str;
                        }else{
                            return '';
                        }
                    }, title: '权限标识'
                },
                {field: 'menuUrl', title: '菜单url',edit: 'text'},
                {field: 'orderNumber', width: 80, align: 'center', title: '排序号'},
                {
                    field: 'isMenu', width: 80, align: 'center', templet: function (d) {
                        if (d.isMenu == 1) {
                            return '<span class="layui-badge layui-bg-gray">按钮</span>';
                        }
                        if (d.parentId == -1) {
                            return '<span class="layui-badge layui-bg-blue">目录</span>';
                        } else {
                            return '<span class="layui-badge-rim">菜单</span>';
                        }
                    }, title: '类型'
                },
                {templet: '#auth-state', width: 120, align: 'center', title: '操作'}
            ]],
            done: function () {
                layer.closeAll('loading');
            }
        });

        $('#btn-expand').click(function () {
            treeTable.expandAll('#munu-table');
        });

        $('#btn-fold').click(function () {
            treeTable.foldAll('#munu-table');
        });

        //监听工具条
        table.on('tool(munu-table)', function (obj) {
            var data = obj.data;
            var layEvent = obj.event;

            if (layEvent === 'del') {
                layer.msg('删除' + data.id);
            } else if (layEvent === 'edit') {
                layer.msg('修改' + data.id);
            }
        });
    });
</script>
</body>
</html>